package com.event.controller;

import com.event.pojo.Article;
import com.event.pojo.PageBean;
import com.event.pojo.Result;
import com.event.service.ArticleService;
import com.event.utils.JwtUtil;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    @PostMapping("/addArticle")
    public Result addArticle(@RequestBody @Validated Article article) {
        articleService.addArticleAction(article);
        return Result.success("添加成功1111");
    }

    @GetMapping("/queryArticleList")
    public Result<PageBean<Article>> queryArticleList(
            Integer pageNum,
            Integer pageSize,
            @RequestParam(required = false)   Integer categoryId,
            @RequestParam(required = false) String state
    ){
        PageBean<Article> article= articleService.queryArticleList(pageNum,pageSize,categoryId,state);
        return Result.success(article);

    }
}
